package com.jvm.interpreter.instruction;

import com.jvm.classfile.model.CpInfo;
import com.jvm.interpreter.Frame;
import com.jvm.interpreter.Instruction;

/**
 * @program: diy_simple_jvm
 * @description: iconst_1指令
 * @author: CaoYong
 * @create: 2021-07-08 10:14
 **/
public class IConst1Inst implements Instruction {

    /**
     * 将常量1推送到当前栈帧的操作数栈栈顶
     * @param frame 栈帧
     */
    @Override
    public void eval(Frame frame) {
//        frame.operandStack.push(1);
        frame.pushInt(1);
        frame.pc += offset();
    }

    static IConst1Inst parse(java.io.DataInputStream dis, CpInfo[] cp) throws java.io.IOException {
        return new IConst1Inst();
    }
}
